package com.hy.mvc.web.conroller;

import com.alibaba.fastjson.JSON;
import com.hy.mvc.biz.service.manager.UUserDOManager;
import com.hy.mvc.biz.utils.CaptchaUtil;
import com.hy.mvc.biz.utils.application.ApplicationConextUtil;
import com.hy.mvc.domain.dataobject.UUserDO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/**
 * <pre>
 *    author  : Booker
 *    time    : 2017/12/13 17:30
 *    desc    : show the function of this class
 *    version : v1.0
 * </pre>
 */
@Controller
@RequestMapping("test")
@Api("测试接口")
public class TestController {

    @Resource
    private CaptchaUtil captchaUtil;
    /**
     * 通过ApplicationConextUtil 诸如bean
     * @param modelMap
     * @return
     */
    @RequestMapping(value = "/app", method = RequestMethod.GET)
    @ApiOperation("Allication查询所有")
    public @ResponseBody
    String testFindAll(ModelMap modelMap) {
        UUserDOManager manager =  (UUserDOManager)ApplicationConextUtil.getBean("UUserDOManager");
        List<UUserDO> list = manager.findAllValidUUserDO();
        return JSON.toJSONString(list);
    }

}
